import { GCellRenderer } from "../../../com/mui/controls/GCellRenderer";
import { ItemData } from "../resource/info/ItemData";
import { GBitmap } from "../../../com/mui/controls/GBitmap";
import { BaseItem } from "./common/BaseItem";
import { GlobalClass } from "../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../resource/ImagesConst";
type int = number;
//class ItemShowRenderer
    
    export  class ItemShowRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        public get isBigSize(): Boolean
        {
            return this._isBigSize;
        }

        public set isBigSize(arg1: Boolean)
        {
            this._isBigSize = arg1;
            if (this._bgBmp && this._baseItem && this._data) 
            {
                this.setItemSize();
            }
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            var loc2=0;
            super.data = arg1;
            if (arg1 is int || !(arg1.data == null) && arg1.data is int || !(arg1.itemData == null) && arg1.itemData is int) 
            {
                if (typeof arg1 === "int") 
                {
                    loc2 = arg1 as int;
                }
                else if (typeof arg1.data === "int") 
                {
                    loc2 = arg1.data as int;
                }
                else if (!(arg1.itemData == null) && arg1.itemData is int) 
                {
                    loc2 = arg1.itemData as int;
                }
                loc1 = new ItemData(loc2);
            }
            else if (arg1 is ItemData || !(arg1.data == null) && arg1.data is ItemData || !(arg1.itemData == null) && arg1.itemData is ItemData) 
            {
                if (typeof arg1 === "itemdata") 
                {
                    loc1 = arg1 as ItemData;
                }
                else if (!(arg1.data == null) && arg1.data is ItemData) 
                {
                    loc1 = arg1.data as ItemData;
                }
                else if (!(arg1.itemData == null) && arg1.itemData is ItemData) 
                {
                    loc1 = arg1.itemData as ItemData;
                }
            }
            if (loc1) 
            {
                if (!this._bgBmp) 
                {
                    this._bgBmp = new GBitmap();
                    this.addChild(this._bgBmp);
                }
                if (!this._baseItem) 
                {
                    this._baseItem = new BaseItem();
                    this._baseItem.isDragAble = false;
                    this.addChild(this._baseItem);
                }
                this._baseItem.itemData = loc1;
                this.setItemSize();
            }
            return;
        }

        /* internal  */setItemSize(): void
        {
            var loc1=NaN;
            if (this._isBigSize) 
            {
                this._bgBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.PropBg);
                loc1 = 60;
            }
            else 
            {
                this._bgBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.PackItemBg);
                loc1 = 32;
            }
            this._baseItem.setSize(loc1, loc1);
            var loc2=(this._bgBmp.width - loc1) / 2;
            var loc3=(this._bgBmp.height - loc1) / 2;
            this._baseItem.move(loc2, loc3);
            return;
        }

        protected /* var */_baseItem: BaseItem;

        protected /* var */_isBigSize: Boolean=false;

        protected /* var */_bgBmp: GBitmap;
    }
